# -*-coding:utf-8-*-

import wx

log_level = 4
log_path = "log/log.txt"
log_textPanel = None


def error(msg):
    if (log_level >= 1):
        print ("Error#  " + msg)
        #f = open(log_path, 'a', 0)
        #f.write("Error#  " + msg.encode("utf-8") + "\n")
        #f.close()
    else:
        pass

def warn(msg):
    if (log_level >= 2):
        print ("Warn #  " + msg)
        #f = open(log_path, 'a', 0)
        #f.write("Warn #  " + msg.encode("utf-8") + "\n")
        #f.close()
    else:
        pass

def info(msg):
    if (log_level >= 3):
        print ("Info #  " + msg)
        #f = open(log_path, 'a', 0)
        #f.write("Info #  " + msg.encode("utf-8") + "\n")
        #f.close()
    else:
        pass

def debug(msg):
    if (log_level >= 4):
        print ("Debug#  " + msg)
        #f = open(log_path, 'a', 0)
        #f.write("Debug#  " + msg.encode("utf-8") + "\n")
        #f.close()
    else:
        pass

def TestLog(msg,status=''):
    if log_textPanel != None:
        if status == "F":
            log_textPanel.SetDefaultStyle(wx.TextAttr("RED"))
        elif status == "T":
            log_textPanel.SetDefaultStyle(wx.TextAttr("BLUE"))
        else:
            log_textPanel.SetDefaultStyle(wx.TextAttr("BLUE"))
        log_textPanel.AppendText(msg.encode("gbk") + "\n")
        #log_textPanel.AppendText(msg + "\n")
    else:
        print(msg)
